home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 56804 / 56804.xpi / chrome / content / seostatus.js < prev    next >
Text File  |  2010-01-31  |  5KB  |  132 lines

  1. if(!com) var com={};
  2. if(!com.seostatus) com.seostatus={};
  3.  
  4. com.seostatus.seostatus =  function(){
  5.   var pub = {};
  6.   pub.customButtonClicked = function(){
  7.       
  8.       var mainBar = document.getElementById('SEOTB-Toolbar');
  9.       var onOrOff = mainBar.hidden;
  10.       mainBar.setAttribute("hidden", !onOrOff);
  11.   }
  12.   
  13.   ////////////////////////////////////////////////////////////////////////////////
  14.   // The SEOTB_Search() function will perform a Google search for us. The two
  15.   // parameters that get passed in are the event that triggered this function
  16.   // call, and the type of search to perform.
  17.   ////////////////////////////////////////////////////////////////////////////////
  18.   
  19.   pub.SEOPageRank_Action = function(event, type)
  20.   {
  21.       // This variable will hold the URL we will browse to
  22.       var URL = "";
  23.       
  24.       var isEmpty = false;
  25.       
  26.       if (content.document.location.length < 12) {isEmpty = true; }
  27.       
  28.       switch(type)
  29.       {
  30.       // Build up the URL for an image search
  31.       case "value":
  32.           if(isEmpty) { URL = "http://www.rubyweb.org/"; }
  33.           else        { URL = "http://www.sitevaluecalculator.com/result.php?domain=" + escape(content.document.location) + "&ref=stb"; }
  34.           break;
  35.           
  36.       case "whois":
  37.           if(isEmpty) { URL = "http://www.rubyweb.org/"; }
  38.           else        { URL = "http://www.rapidsitecheck.com/whois.php?domain=" + escape(content.document.location) + "&ref=stb"; }
  39.           break;
  40.    
  41.       case "backlinks":
  42.           if(isEmpty) { URL = "http://www.rubyweb.org/"; }
  43.           else        { URL = "http://www.rapidsitecheck.com/pagerank-backlinks.php?domain=" + escape(content.document.location) + "&ref=stb"; }
  44.           break; 
  45.   
  46.       case "dynamicdomain":
  47.           if(isEmpty) { URL = "http://www.rubyweb.org/"; }
  48.           else        { URL = "http://www.rapidsitecheck.com/domain-lookup.php?domain=" + escape(content.document.location) + "&ref=stb" + 
  49.                                 "&net=true&us=true&org=true&info=true&biz=true"; }
  50.           break;
  51.    
  52.       case "dig":
  53.           if(isEmpty) { URL = "http://www.rubyweb.org/"; }
  54.           else        { URL = "http://www.rapidsitecheck.com/all-datacenters.php?domain=" + escape(content.document.location) + "&ref=stb"; }
  55.           break;
  56.           
  57.       case "alexa":
  58.           if(isEmpty) { URL = "http://www.alexa.com/"; }
  59.           else        { URL = "http://www.alexa.com/data/details/traffic_details?q=&url=" + escape(content.document.location) + "&ref=stb"; }
  60.           break;
  61.           
  62.       case "google":
  63.           if(isEmpty) { URL = "http://www.google.com/"; }
  64.           else        { URL = "http://www.google.com/search?q=cache%3A" + escape(content.document.location) + "&ref=stb"; }
  65.           break;
  66.       }
  67.       
  68.       // Load the URL in the browser window using the goto_page function
  69.       pub.goto_page(URL);
  70.   }
  71.   
  72.   ////////////////////////////////////////////////////////////////////////////////
  73.   // The SEOTB_TrimString() function will trim all leading and trailing whitespace
  74.   // from the incoming string, and convert all runs of more than one whitespace
  75.   // character into a single space. The altered string gets returned.
  76.   ////////////////////////////////////////////////////////////////////////////////
  77.   pub.SEOTB_TrimString = function(string)
  78.   {
  79.       // If the incoming string is invalid, or nothing was passed in, return empty
  80.       if (!string)
  81.           return "";
  82.   
  83.       string = string.replace(/^\s+/, ''); // Remove leading whitespace
  84.       string = string.replace(/\s+$/, ''); // Remove trailing whitespace
  85.   
  86.       // Replace all whitespace runs with a single space
  87.       string = string.replace(/\s+/g, ' ');
  88.   
  89.       return string; // Return the altered value
  90.   }
  91.   
  92.   ////////////////////////////////////////////////////////////////////////////////
  93.   // The goto_page() function loads the specified URL in the browser.
  94.   ////////////////////////////////////////////////////////////////////////////////
  95.   pub.goto_page = function(url)
  96.   {
  97.       // Set the browser window's location to the incoming URL
  98.       window._content.document.location = url;
  99.   
  100.       // Make sure that we get the focus
  101.       window.content.focus();
  102.   }
  103.   
  104.   ////////////////////////////////////////////////////////////////////////////////
  105.   // The SEOTB_KeyHandler() function checks to see if the key that was pressed
  106.   // is the [Enter] key. If it is, a web search is performed.
  107.   ////////////////////////////////////////////////////////////////////////////////
  108.   pub.SEOTB_KeyHandler = function(event)
  109.   {
  110.       // Was the key that was pressed [ENTER]? If so, perform a web search.
  111.       if(event.keyCode == event.DOM_VK_RETURN)
  112.           pub.SEOPageRank_Action(event, 'web');
  113.   }
  114.   
  115.   
  116.   pub.showOptions = function()
  117.   {
  118.       window.openDialog( "chrome://seostatus/content/options.xul", "seostatus-options-dialog", "centerscreen,chrome,modal" );
  119.   }
  120.   
  121.   
  122.   pub.showAbout = function()
  123.   {
  124.       window.openDialog( "chrome://seostatus/content/about.xul", "seostatus-about-dialog", "centerscreen,chrome,modal" );
  125.   }
  126.   return pub;
  127. }();
  128.  
  129.     
  130.     
  131.  
  132.